package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.RiverInfoRequest;
import cn.stylefeng.guns.modular.business.service.RiverInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 河道信息表控制器
 *
 * @author zhangyaowen
 * @date 2021/10/08 16:51
 */
@RestController
@ApiResource(name = "河道信息表")
public class RiverInfoController {

    @Resource
    private RiverInfoService riverInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "添加", path = "/riverInfo/add")
    public ResponseData add(@RequestBody @Validated(RiverInfoRequest.add.class) RiverInfoRequest riverInfoRequest) {
        riverInfoService.add(riverInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "删除", path = "/riverInfo/delete")
    public ResponseData delete(@RequestBody @Validated(RiverInfoRequest.delete.class) RiverInfoRequest riverInfoRequest) {
        riverInfoService.del(riverInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "编辑", path = "/riverInfo/edit")
    public ResponseData edit(@RequestBody @Validated(RiverInfoRequest.edit.class) RiverInfoRequest riverInfoRequest) {
        riverInfoService.edit(riverInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "查看详情", path = "/riverInfo/detail")
    public ResponseData detail(@Validated(RiverInfoRequest.detail.class) RiverInfoRequest riverInfoRequest) {
        return new SuccessResponseData(riverInfoService.detail(riverInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "获取列表", path = "/riverInfo/list")
    public ResponseData list(RiverInfoRequest riverInfoRequest) {
        return new SuccessResponseData(riverInfoService.findList(riverInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "分页查询", path = "/riverInfo/page")
    public ResponseData page(RiverInfoRequest riverInfoRequest) {
        return new SuccessResponseData(riverInfoService.findPage(riverInfoRequest));
    }

    /**
     * 获取河道详情
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "获取河道详情", path ="/riverInfo/toReview")
    public ResponseData toReview(String name) {
        return new SuccessResponseData(riverInfoService.toReview(name));
    }

}